package application;

import inference.LDALingPipe;


import java.io.File;

import java.io.FileWriter;
import java.io.PrintWriter;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Map;

import org.gps.utils.LatLonPoint;


import parser.TwitterParser;
import utils.config.Config;
import utils.kml.Kml;



public class MainTwitterTopic {
	
	public static ArrayList<Integer> DAYSOFWEEK;
	public static ArrayList<Integer> MONTHS;
	

	
	public static void main(String[] args) throws Exception{
		
		new MainTwitterTopic().run();
		
	}
	
	public void run() throws Exception{
		
		Config config = new Config(this.getClass().getSimpleName()+".ser");
		final String FILENAME = (String)config.get("FILENAME");
		final String LDAPATH = (String)config.get("LDAPATH");
		final String INCSV = (String)config.get("INCSV");
		final String OUTKML = (String)config.get("OUTKML");
		final String OUTCSV = (String)config.get("OUTCSV");
		final long SEED = (Long)config.get("SEED");
		final int NUMSAMPLES = (Integer)config.get("NUMSAMPLES");
		final int NUMTOPICS = (Integer)config.get("NUMTOPICS");
		final int CELLSIZE = (Integer)config.get("CELLSIZE");
		final int TIMEINTERVALS = (Integer)config.get("TIMEINTERVALS");
		
		//this function select the days of week and months taken into consideration
		selectDays();
		TwitterParser parser = new TwitterParser(LDAPATH, INCSV, TIMEINTERVALS);
		//create a document for each selected day
		parser.createDocs(DAYSOFWEEK, MONTHS);
		
		LDALingPipe lda = new LDALingPipe();
		lda.run(LDAPATH, OUTKML, OUTCSV, CELLSIZE, SEED, NUMSAMPLES, (short)NUMTOPICS, parser);
		
	}
	
	
	public void selectDays(){
		DAYSOFWEEK = new ArrayList<Integer>();
		Collections.addAll(DAYSOFWEEK, Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY,
				 Calendar.FRIDAY, Calendar.SATURDAY, Calendar.SUNDAY);
		
		
		MONTHS = new ArrayList<Integer>();
		Collections.addAll(MONTHS, Calendar.JANUARY, Calendar.FEBRUARY, Calendar.APRIL, Calendar.MAY, Calendar.JUNE,
				Calendar.JULY, Calendar.AUGUST, Calendar.SEPTEMBER, Calendar.OCTOBER, Calendar.NOVEMBER, Calendar.DECEMBER);
	}

}
